Skip to content

docs: split CLAUDE.md into per-directory guides#1846

Merged
kixelated merged 7 commits into
mainfrom
claude/claude-md-organization-prpk6u
Jun 22, 2026
Merged

docs: split CLAUDE.md into per-directory guides#1846
kixelated merged 7 commits into
mainfrom
claude/claude-md-organization-prpk6u

Conversation

@kixelated

@kixelated kixelated commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Splits the monolithic root CLAUDE.md into per-directory guides that load automatically when an agent works under each language directory. The root file now holds only cross-cutting rules; language-specific detail (and a richer module map than the root previously had) lives next to the code it describes.

Why nested files, not @imports or skills: nested CLAUDE.md is the only mechanism that loads conditionally by location, so a Rust-only session no longer carries JS reactivity rules and vice versa. @import would load eagerly (no savings); skills are for actions (a pre-PR self-review skill is a sensible follow-up, but that is a separate concern from this reference knowledge).

New nested guides

  • rs/CLAUDE.md - Cargo workspace: crate map (including kio, moq-json, moq-loc, moq-msf, moq-video that the root tree omitted), Producer/Consumer model, poll_* plumbing, error handling, config/TOML merge, Version matching, binary setup, testing.
  • js/CLAUDE.md - bun workspace: package map grouped by role (Foundation / Transport / Container formats / Media / Apps), the signals + Effect reactivity model and its lifecycle/cleanup rules, the Web Components UI pattern, bun/Biome tooling.
  • py/CLAUDE.md - the moq-ffi (generated bindings) vs moq-rs (ergonomic wrapper) split, the moq public surface, and the release/versioning mechanics for both PyPI distributions.

Root CLAUDE.md changes

  • New Per-Directory Guides section pointing at each nested file.
  • Replaced the per-crate/per-package Project Structure tree with a compact top-level map; the rot-prone detail now lives in the nested guides.
  • Added a Language Bindings section: rs/moq-ffi is the single UniFFI core powering py/swift/kt/go, with rs/libmoq exposing it as a C staticlib.
  • Removed Version Matching Convention and Rust Conventions (folded into rs/CLAUDE.md).
  • Trimmed the four JS-specific Tooling bullets (folded into js/CLAUDE.md); kept the cross-cutting ones (just, Nix, Local-first, CI).
  • Extended the PR Reviews section: when CodeRabbit can't produce a review, run /review locally and act on the findings (push the high-confidence fixes, escalate ambiguous ones by asking first).
  • swift/, kt/, go/ are thin wrappers mirrored to external repos, so they defer to their existing README.mds.

Review-driven fixes

  • rs/CLAUDE.md: added a convention to prefer kio over tokio::sync primitives (a channel or watch with a single value is a code smell); corrected the moq-net note (submodules are private and re-exported flat, not public).
  • Inline doc comments in three Rust source files (moq-relay/src/config.rs, moq-relay/src/stats.rs, moq-bench/src/config.rs) now reference rs/CLAUDE.md, where the config/TOML-merge guidance moved.
  • Bumped rs/moq-gst from edition 2021 to 2024 (it was the only crate not on 2024) with the rustfmt import reorder that edition 2024 requires.

Public API changes

None. The only non-docs change is the moq-gst edition bump (no behavioral or API change).

Test plan

  • Root file re-reads coherently; the moved sections are gone and the pointer sections resolve.
  • No em dashes introduced (the only is the literal one inside the "no em dashes" rule).
  • cargo fmt -p moq-gst clean; CI builds moq-gst on edition 2024 in Nix.

Follow-ups (not in this PR)

  • A pre-submit self-review skill that leans on the Cross-Package Sync table and public-API/breaking-change rules.
  • Further root consolidation (the just commands and "use just" are repeated across Common Commands / Development Tips / Testing Approach / Workflow).

(Written by Claude)

🤖 Generated with Claude Code


Generated by Claude Code

Add nested CLAUDE.md files that load automatically when working under
each language directory, keeping the root file to cross-cutting rules.

- rs/CLAUDE.md: crate map, Producer/Consumer model, poll_* plumbing,
  error handling, config/TOML merge, Version matching, testing. Folds in
  the root "Version Matching Convention" and "Rust Conventions" sections.
- js/CLAUDE.md: package map, signals + Effect reactivity lifecycle, Web
  Components UI, bun/Biome tooling. Folds in the JS-specific Tooling
  bullets (TypeScript/bun, Biome, UI, JS async patterns).
- py/CLAUDE.md: the moq-ffi vs moq-rs split and the moq public surface.

Root CLAUDE.md gains a "Per-Directory Guides" section pointing at each
nested file and now holds only universal rules. swift/kt/go are thin
wrappers and defer to their READMEs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSWQ8HdasmrvfCcR9P2QiA
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The root CLAUDE.md is restructured with a new Per-Directory Guides section pointing agents to rs/CLAUDE.md, js/CLAUDE.md, py/CLAUDE.md, and README.md files for swift/kt/go wrappers. The Writing Style section is trimmed to only the no-em-dash rule, removing Rust conventions and version-matching guidance. The Tooling section replaces language-specific bullets with a pointer to per-directory guides. The PR Reviews section clarifies conditions for using local /review. Three new guide files are created: rs/CLAUDE.md covers the Rust workspace, crate map, Producer/Consumer model, and async/poll conventions; js/CLAUDE.md covers the Bun workspace, Signals/Effect reactivity, and web component conventions; py/CLAUDE.md covers the moq-ffi/moq-rs wheel split and module layout. Inline documentation in three Rust source files is updated to reference rs/CLAUDE.md, and the moq-gst crate edition is bumped from 2021 to 2024 with import reordering.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: split CLAUDE.md into per-directory guides' directly and accurately summarizes the main change: reorganizing documentation by splitting a monolithic file into language-specific nested guides.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description comprehensively documents the reorganization of CLAUDE.md into language-specific nested guides, explains the rationale (conditional loading by location), details new guide contents, and summarizes root file changes, review feedback, and testing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/claude-md-organization-prpk6u

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rs/CLAUDE.md`:
- Around line 72-79: The docstring comment containing "see `CLAUDE.md`" in
relation to TOML/CLI merge guidance needs to be updated after the documentation
reorganization. Find the comment that references CLAUDE.md for TOML merge/CLI
interaction rules and update it to reference rs/CLAUDE.md instead, ensuring the
external documentation link points to the correct location of the configuration
conventions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b7b598ac-a70e-40a6-b94c-ead8fbf097bf

📥 Commits

Reviewing files that changed from the base of the PR and between dbb41d8 and ab28431.

📒 Files selected for processing (4)
  • CLAUDE.md
  • js/CLAUDE.md
  • py/CLAUDE.md
  • rs/CLAUDE.md

Comment thread rs/CLAUDE.md
claude added 3 commits June 21, 2026 01:49
The "Config flags + TOML merge" guidance moved from the root CLAUDE.md
into rs/CLAUDE.md, so update the three doc comments that reference it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSWQ8HdasmrvfCcR9P2QiA
The previous run died on an sccache "Connection reset by peer" while
compiling a third-party crate, unrelated to this docs-only change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSWQ8HdasmrvfCcR9P2QiA
When CodeRabbit can't produce a review, the existing rule says to run
/review locally. Spell out the follow-through: push high-confidence
fixes directly and escalate ambiguous ones by asking first.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSWQ8HdasmrvfCcR9P2QiA
Comment thread js/CLAUDE.md Outdated

## Workspace layout

Bun workspaces; members listed in the repo-root `package.json` (not in `js/`). Deps hoist to the repo root `node_modules`, not into `js/`. Run recipes via `just js <recipe>` (see `js/justfile`). The root `CLAUDE.md` lists only 8 packages; there are more. Full set, in dependency order:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root CLAUDE.md lists only 8 packages; there are more.

Don't have the root claude.md list them then.

Comment thread rs/CLAUDE.md Outdated

Reference for the `/rs` Cargo workspace. Universal rules (writing style, no em dashes, Branch Targeting, Cross-Package Sync, Public API Scrutiny, Refactor As You Go, AI Attribution) live in the root `/CLAUDE.md` and are not repeated here.

Workspace members live in the root `Cargo.toml` (`[workspace]`). `rust-version = "1.85"`, edition 2024 for most crates (moq-gst is 2021). Shared versions/paths are pinned under `[workspace.dependencies]`; new crates should add their dep there and reference it via `{ workspace = true }`.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edition 2024 for most crates (moq-gst is 2021)

Can you fix that?

Comment thread rs/CLAUDE.md Outdated
Layered roughly transport -> container/format -> media -> apps/bindings.

**Transport / protocol**
- `moq-net` (lib): the core wire layer. Negotiates `moq-lite` or IETF `moq-transport`. Owns the Broadcast/Track/Group/Frame model and the Producer/Consumer split (see below). Generic over `web_transport_trait::Session` (no concrete QUIC dep). `lite/` and `ietf/` modules are private; `model/`, `error`, `version`, `coding`, `path`, `session`, `client`, `server` are public.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all of those modules public? Is it even worth mentioning this?

Comment thread js/CLAUDE.md

Bun workspaces; members listed in the repo-root `package.json` (not in `js/`). Deps hoist to the repo root `node_modules`, not into `js/`. Run recipes via `just js <recipe>` (see `js/justfile`). The root `CLAUDE.md` lists only 8 packages; there are more. Full set, in dependency order:

- `@moq/signals` (`signals/`): reactive core. `Signal`, `Computed`, `Effect`, plus framework adapters at subpaths `./solid`, `./react`, `./dom`. No deps on other workspace packages. Everything below uses it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split these into categories like Rust?

Comment thread rs/CLAUDE.md
- **Errors**: `thiserror` with `#[from]` for libraries, `anyhow` (with `.context("...")`, not `.map_err(|_| anyhow!())`) for binaries. Always `#[non_exhaustive]` on public error enums (e.g. `moq-net/src/error.rs:6`, `moq-ffi/src/error.rs:4`, `moq-loc/src/lib.rs:55`). Use `#[error(transparent)]` + `#[from]` for wrapped foreign errors (see `moq-token/src/error.rs`).
- **Config + TOML merge**: any `#[arg]` field on a TOML-loadable config must be `Option<T>`, never a bare `bool`/`String`/etc. The TOML->CLI merge re-applies clap defaults and silently clobbers TOML values for bare fields. See `moq-relay/src/config.rs` and its regression tests (`cli_does_not_clobber_toml_*`, around line 126); add such a test for any new flag.
- **Config structs**: `#[derive(Parser, Serialize, Deserialize)]` with `#[serde(deny_unknown_fields, default)]`, clap `#[arg(long, env = "MOQ_...")]`, nested configs via `#[command(flatten)]`, and an `.init()`/`.load()` method that produces the live object. Add `#[non_exhaustive]` + `Default`/constructor to configs consumers build (per root Public API Scrutiny).
- **Unwrapping**: prefer `if let Some(v) = x { ... }` / `let Some(v) = x else { ... };` over a `match` whose only job is to bind the inner value. Keep `match` when both arms do real work.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note that match Option can usually be simpler as if let

Comment thread CLAUDE.md

Key architectural rule: The CDN/relay does not know anything about media. Anything in the `moq` layer should be generic, using rules on the wire on how to deliver content.

## Project Structure

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this worth having, especially if out of date?

Comment thread CLAUDE.md Outdated

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a section about moq-ffi, and how it powers python/kotlin/go/swift, would be good?

Review-driven changes to the CLAUDE.md guides:
- Trim the root Project Structure to a top-level map. Per-crate/package
  detail lives in the nested guides and was rotting in root.
- Add a Language Bindings section: rs/moq-ffi is the single UniFFI core
  powering py/swift/kt/go, with libmoq exposing it as a C staticlib.
- Move the py release/versioning detail into py/CLAUDE.md (root no longer
  carries it, and py/CLAUDE.md no longer points back at root for it).
- Categorize the js/CLAUDE.md package list by role, mirroring rs.
- Fix rs/CLAUDE.md: moq-net submodules are private and re-exported flat
  from the crate root, not public.
- Add a Rust convention: prefer kio over tokio sync primitives; a channel
  or watch carrying a single value is a code smell.

Also bump moq-gst from edition 2021 to 2024 (it was the only crate not on
2024) and drop the exception note in rs/CLAUDE.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSWQ8HdasmrvfCcR9P2QiA

Copy link
Copy Markdown
Collaborator Author

Addressed the review in a5ae1fa:

  • rs/CLAUDE.md:12 (are those modules public?) No, none of them are. moq-net/src/lib.rs declares every submodule private and re-exports flat (pub use model::*, etc.). Reworded to "submodules are private; the public surface is re-exported flat from the crate root" and dropped the (incorrect) module list.
  • rs/CLAUDE.md:5 (fix the edition split) Bumped moq-gst from edition 2021 to 2024 (it was the only laggard) and removed the exception note. Caveat: gstreamer dev libs aren't available in this environment, so I couldn't compile-verify locally. No edition-2024 hazards (set_var, static mut, gen, RPIT captures) appear in the crate's source, so I expect it clean; CI builds moq-gst in Nix and will confirm.
  • js/CLAUDE.md:9 (categorize like Rust) Grouped the packages into Foundation / Transport / Container formats / Media / Apps, mirroring the Rust crate map.
  • js/CLAUDE.md:7 + root (don't list packages in root) Removed the "root lists only 8" remark, and the root Project Structure no longer enumerates packages at all (see below).
  • CLAUDE.md:40 (is the tree worth having if out of date?) Replaced the full directory tree with a compact top-level map that points at the nested guides, so the rot-prone per-crate/package detail lives next to the code. Moved the py release/versioning detail into py/CLAUDE.md.
  • CLAUDE.md:55 (moq-ffi section) Added a Language Bindings section explaining rs/moq-ffi is the single UniFFI core powering py/swift/kt/go, with libmoq exposing it as a C staticlib.
  • rs/CLAUDE.md:77 (match Option -> if let) Already covered by the existing "Unwrapping" bullet; left as is.
  • kio over tokio Added a Rust convention: prefer kio over tokio::sync primitives; a channel or watch carrying a single value is a code smell.

(Written by Claude)


Generated by Claude Code

The edition 2024 bump changes rustfmt's import ordering (lowercase items
sort after types), so cargo fmt rewrites this import group.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSWQ8HdasmrvfCcR9P2QiA
@kixelated kixelated enabled auto-merge (squash) June 22, 2026 02:43
The previous push did not fire a pull_request workflow run, so no required
check was created and auto-merge is stuck. Nudge a fresh synchronize event.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TSWQ8HdasmrvfCcR9P2QiA
@kixelated kixelated merged commit 67cfee2 into main Jun 22, 2026
1 check passed
@kixelated kixelated deleted the claude/claude-md-organization-prpk6u branch June 22, 2026 03:09
This was referenced Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants